home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / ref.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  2.0 KB  |  79 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  REF.H                                                                 */
  4. /*                                                                        */
  5. /*------------------------------------------------------------------------*/
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.0
  9.  *
  10.  *      Copyright (c) 1987, 1998 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   9.1  $ */
  15.  
  16. #ifndef __cplusplus
  17. #error Must use C++ for REF.H
  18. #endif
  19.  
  20. #ifndef __REF_H
  21. #define __REF_H
  22.  
  23. /*
  24.  *
  25.  * Base class for reference counting
  26.  *
  27.  */
  28.  
  29. #if !defined(___DEFS_H)
  30. #include <_defs.h>
  31. #endif
  32.  
  33. #if !defined(RC_INVOKED)
  34.  
  35. #if defined(__STDC__)
  36. #pragma warn -nak
  37. #endif
  38.  
  39. #endif  /* !RC_INVOKED */
  40.  
  41.  
  42. /*------------------------------------------------------------------------*/
  43. /*                                                                        */
  44. /*  class TReference                                                      */
  45. /*                                                                        */
  46. /*  Base class for reference counting                                     */
  47. /*                                                                        */
  48. /*------------------------------------------------------------------------*/
  49.  
  50. class _EXPCLASS TReference
  51. {
  52.  
  53. public:
  54.  
  55.     _RTLENTRY TReference(unsigned short initRef = 0) : Refs(initRef) { }
  56.     void _RTLENTRY AddReference() { Refs++; }
  57.     unsigned short _RTLENTRY References() { return Refs; }
  58.     unsigned short _RTLENTRY RemoveReference() { return --Refs; }
  59.  
  60. private:
  61.  
  62.     unsigned short Refs;    // Number of references to this block
  63.  
  64. };
  65.  
  66. #if defined( BI_OLDNAMES )
  67. #define BI_Reference TReference
  68. #endif
  69.  
  70. #if !defined(RC_INVOKED)
  71.  
  72. #if defined(__STDC__)
  73. #pragma warn .nak
  74. #endif
  75.  
  76. #endif  /* !RC_INVOKED */
  77.  
  78. #endif  // __REF_H
  79.